<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <link rel="stylesheet" href="../lib/bootstrap-3.4.1-dist/css/bootstrap.min.css">
  <script src="../lib/jquery/jquery.min.js"></script>
  <script src="../lib/bootstrap-3.4.1-dist/js/bootstrap.min.js"></script>
  <script src="../js/cookie.js"></script>
</head>

<body>
  <div class="container">
    <form class="form-horizontal able">
      <div class="form-group">
        <label for="inputEmail3" class="col-sm-2 control-label">账号</label>
        <div class="col-sm-10">
          <input type="text" class="form-control" id="count" placeholder="账号">
        </div>
      </div>
      <div class="form-group">
        <label for="inputPassword3" class="col-sm-2 control-label">密码</label>
        <div class="col-sm-10">
          <input type="password" class="form-control" id="pwd" placeholder="密码">
        </div>
      </div>
      <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10">
          <div class="checkbox">
            <a href="./design.html">去注册</a>
          </div>
        </div>
      </div>
      <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10">
          <button type="button" class="btn btn-default">登录</button>
        </div>
      </div>
    </form>
  </div>
</body>
<script>
  $(function () {
    $('button').click(function () {
      let count = $('.able').find('#count').val()
      let pwd = $('.able').find('#pwd').val()
      $.ajax({
        type: 'post',
        url: 'https://api.it120.cc/conner/user/username/login',
        data: {
          deviceId: 'ADS4-DIOP-DDS0-DAOO9',
          deviceName: 'IPHONE13',
          username:count,
          pwd
        }
      }).then(res=>{
        console.log(res)
        if(res.code==0){
          setCookie('token',res.data.token)
          setCookie('uid',res.data.uid)
          let resoult=confirm('登录成功，点击跳转区首页')
          if(resoult){
            location.href='./index.html'
          }
        }else{
          alert(res.msg)
        }
      })
    })
  })
</script>

</html>